﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using TFSCommon.Settings;

namespace TFSCommon
{
    public class MyBugtracker : Common.Bugtracker
    {
        public MySettingsManager Settings
        {
            get { return settings_ as MySettingsManager; }
        }

        private TFSProvider tfsp_ = null;

        public MyBugtracker(MySettingsManager settings)
            : base(settings) { }

        protected override void SetSteps()
        {
            validation_steps_texts_ = new string[] { "Validating Server Address...", "Connecting to Server...", "Validating Project Name..." };
        }

        protected override bool RunCurrentStep(int current_step)
        {
            if (current_step == 0)
            {
                if (!Uri.IsWellFormedUriString(Settings.CollectionUri, UriKind.Absolute))
                    return false;
            }
            else if (current_step == 1)
            {
                tfsp_ = new TFSProvider(Settings);
                tfsp_.Connect();
            }
            else if (current_step == 2)
            {
                if (!tfsp_.ProjectExists(Settings.Project))
                    return false;
            }

            return true;
        }
    }
}
